<template>
	<view>
		<button v-if="false" @click="open">打开弹窗</button>
		<uni-popup ref="popup" type="bottom">
			<text v-if="false" class="text">Popup</text> 
			<view class="popou-box">
				<view class="p-header">
					<text class="p-title"
					>分享至</text>
				</view>
				<view class="p-list">
					<!-- 已配置SharelistConfing -->
					<view class="p-item"
					v-for="(item,index) in shareData" :key="index"
					v-if="item.isShow"
					@click="ShareItemTap(index,item)">
						<view class="p-Image-box">
							<image class="p-Image" mode="widthFix"
							:src="item.image"></image>
						</view>
						<text class="text-name"
						>{{item.name}}</text>
					</view>
				</view>
				<view class="p-cell" @click="close">
					<text class="p-title"
					>取消</text>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	// 导入静态分享文件数据
	import MixinsShareData from './mixins/shareData.js'
	export default {
		name:"FatFatMeng-PopupShare",
		mixins:[
			MixinsShareData
		],
		props:{
			SharelistConfing:{
				type:Array,
				default:()=>[]
			}
		},
		data() {
			return {
				
			};
		},
		created(){
			if (this.SharelistConfing.length!=0){
				this.shareData = this.SharelistConfing
			}else {
				// 使用内置默认的数据
			}
		},
		methods:{
			// 打开弹窗
			open(){
			// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ，type 属性将失效 ，仅支持 ['top','left','bottom','right','center']
			this.$refs.popup.open()
			},
			// 关闭弹窗
			close() {
				this.$refs.popup.close()
			},
			// 点击了分享item项
			ShareItemTap(index,item){
				//console.log("第"+Number(e+1)+"个")
				//不能把item回调回去，因为item是内置的，不是自定义的
				let event = {
					index:Number(index+1),//索引
					name:item.name
				}
				console.log("分享点击")
				console.log(event)
				this.$emit("changeShare",event)
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import './PopupShare.scss';
	// .text {
	// 	color: #333;
	// 	font-size: 36rpx;
	// }
</style>
